//
//  WXPFicoPopView.m
//  MexicoLoan
//
//  Created by WXP on 2025/3/29.
//
//

#import "WXPFicoPopView.h"

@interface WXPFicoPopView ()

@end

@implementation WXPFicoPopView

#pragma mark - lazy
- (UIImageView *)imageBack
{
    if (_imageBack == nil) {
        _imageBack = [UIImageView  new];
        _imageBack.userInteractionEnabled = true;
        _imageBack.widthHeight = XY(SCREEN_WIDTH-LEFT_MARDIN*2, (SCREEN_WIDTH-LEFT_MARDIN*2)/1029*900);
        _imageBack.image = [UIImage imageNamed:@"icon-fico-pop-bg"];
        _imageBack.backgroundColor = [UIColor clearColor];
    }
    return  _imageBack;
}
- (UILabel *)labelContent
{
    if (_labelContent == nil) {
        _labelContent = [UILabel  new];
        _labelContent.numberOfLines = 0;
        _labelContent.lineSpace = 3;
        _labelContent.textColor = COLOR_BLACK;
        _labelContent.font = [UIFont boldSystemFontOfSize:16];
    }
    return  _labelContent;
}
- (UIButton *)btnConfirm
{
    if (_btnConfirm == nil) {
        _btnConfirm = [UIButton  new];
        _btnConfirm.widthHeight = XY(self.imageBack.width-30-30, BUTTON_HEIGHT);
        [GlobalMethod setRoundView:_btnConfirm color:[UIColor clearColor] numRound:BUTTON_HEIGHT/2 width:0];
        _btnConfirm.backgroundColor = COLOR_PRIMARY;
        [_btnConfirm setTitleColor:COLOR_BLACK forState:UIControlStateNormal];
        _btnConfirm.titleLabel.font = [UIFont boldSystemFontOfSize:14];
        [_btnConfirm setTitle:@"Puntuación de crédito" forState:UIControlStateNormal];
        _btnConfirm.tag = 1;
        [_btnConfirm addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    return  _btnConfirm;
}

#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.widthHeight = XY(SCREEN_WIDTH, SCREEN_HEIGHT);
        self.backgroundColor = [UIColor colorWithHexString:@"000000" alpha:0.4];
        self.userInteractionEnabled = true;
        [self addSubView];
    }
    return self;
}

//添加subview
- (void)addSubView{
    [self addSubview:self.imageBack];
    [self.imageBack addSubview:self.labelContent];
    [self.imageBack addSubview:self.btnConfirm];
    //初始化页面
    [self resetViewWithModel:nil];
}

#pragma mark - 点击事件
- (void)btnClick:(UIButton *)sender{
    [NSObject clickFeedback];
    [sender addClickAnimate];
    switch (sender.tag) {
        case 1:
        {
            if(self.blockConfirmClick){
                self.blockConfirmClick();
            }
        }
            break;
        default:
            break;
    }
}

#pragma mark - 刷新view
- (void)resetViewWithModel:(id)model{
    [self.labelContent fitTitle:@"¿Desea aumentar rápidamente el límite de su crédito? Intente autorizar el acceso a los informes de puntuación de FICO." variable:self.imageBack.width-30-30];
    self.labelContent.leftTop = XY(30, Ratio(70));
    
    self.btnConfirm.centerXTop = XY(self.imageBack.width/2, self.labelContent.bottom+Ratio(80));
    self.imageBack.centerXCenterY = XY(SCREEN_WIDTH/2, SCREEN_HEIGHT/2);
}

@end
